﻿using CarparkIMS_Model.Mapping;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace CarparkIMS_Model
{
    class DBClass
    {

    }

    public class BaseEntity
    { 
        public int ID { get; set; }
    }

    public class tbTransaction
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Key]
        public int TransactionID { get; set; }
        public DateTime TransactionDate { get; set; }
        public int TransactionTypeID { get; set; }
        public int? PanelID { get; set; }
        public int? DoorID { get; set; }
        public int? UserID { get; set; }
        public string CardID { get; set; }
        public string TransactionLog { get; set; }
    }

    public class tbDisplayTransaction
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Key]
        public int TransactionID { get; set; }
        public DateTime TransactionDate { get; set; }
        public int TransactionTypeID { get; set; }
        public int? PanelID { get; set; }
        public int? DoorID { get; set; }
        public int? UserID { get; set; }
        public string CardID { get; set; }
        public string TransactionLog { get; set; }
    }

    public class tbDoorStatus
    {
        [Key]
        public int DoorID { get; set; }
        public bool Connected { get; set; }
        public bool ForceOpen { get; set; }
        public bool HeldOpen { get; set; }
        public bool DoorOpen { get; set; }
        public bool DoorUnlock { get; set; }
        public bool SendUnlock { get; set; }
        public bool SendResume { get; set; }
        public bool HeldOpenArmed { get; set; }
        public bool ForceOpenArmed { get; set; }
    }

    public class tbDoor
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Key]
        public int DoorID { get; set; }
        public string Name { get; set; }
        public int PanelID { get; set; }
    }
    public class tbUser
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Key]
        public int UserID { get; set; }
        public string Name { get; set; }
        public string CardID { get; set; }
    }

    public class llqqPlateLog : BaseEntity
    {
        //[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        //[Key]
        //public int ID { get; set; }

        [Display(Name = "ParkingNoCalcType")]
        public int ParkingNoCalcType { get; set; }

        [Display(Name = "車位")]
        public string ParkingPlaceId { get; set; }

        [Display(Name ="車牌")]
        public string plate { get; set; }

        [Display(Name = "日期")]
        public string date { get; set; }
        public int confidence { get; set; }
        [Display(Name = "IP 地址")]
        public string ip { get; set; }
        [Display(Name = "圖片")]
        public string image64 { get; set; }
        public DateTime createdOn { get; set; }
        public DateTime OccuredDatetime { get; set; }
        
        [Display(Name = "車牌是否有效")]
        public bool? isValid { get; set; }
    }

    public partial class llqqPlateLogMapping : CustomEntityTypeConfiguration<llqqPlateLog>
    {
        public override void Configure(EntityTypeBuilder<llqqPlateLog> builder)
        {
            builder.ToTable("llqqPlateLog");
            builder.HasKey(a => a.ID);
            
            //base.Configure(builder);
        }
    }

    public class llqqPlateMapping
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Key]
        public int ID { get; set; }
        public int? UserID { get; set; }
        [Display(Name ="卡編號")]
        public string CardID { get; set; }
        [Display(Name = "車牌號碼")]
        public string PlateNo { get; set; }
        public bool Deleted { get; set; }
    }

    public class llqqCameraDoorMapping
    {

        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Key]
        public int ID { get; set; }
        public string CameraIP { get; set; }
        public int DoorID { get; set; }
        //1 - In, 2 - Out
        public int TransactionTypeID { get; set; }
        public bool Deleted { get; set; }
        public virtual tbDoor Door { get; set; } 
        public string ParkingPlaceId { get; set; }

        public string ParkingPlaceSharpNumber { get; set; }

        public int ParkingNoCalcType { get; set; }
    }

    public class llqqNumberPlate
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Key]
        public long ID { get; set; }

        public int ParkingNoCalcType { get; set; }

        [Display(Name = "車牌號碼")]
        public string NumberPlate { get; set; }
        [MaxLength(256)]
        public  string ParkingPlaceId { get; set; }
        [MaxLength(256)]
        public string ParkingPlaceSharpNumber { get; set; }
        public int LogIdOfStart { get; set; }
        public DateTime StartDatetime { get; set; }
        public int LogIdOfEnd { get; set; }
        public DateTime? EndDatetime { get; set; }
        public int IntervalTimes { get; set; }
        public long DurationTimespan { get; set; } 
        public DateTime CreatedOn { get; set; }
        public DateTime UpdatedOn { get; set; }
        public int IsCompleted { get; set; }
    }
}
